package com.ruoyi.workShop.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
import com.ruoyi.common.utils.StringUtils;
import java.util.List;
import java.util.Map;
import com.ruoyi.workShop.mapper.BdWorkshopMapper;
import com.ruoyi.workShop.domain.BdWorkshop;
import com.ruoyi.workShop.service.IBdWorkshopService;

/**
 * 车间Service业务层处理
 *
 * @author ruoyi
 * @date 2023-11-14
 */
@Service
public class BdWorkshopServiceImpl extends ServiceImpl<BdWorkshopMapper, BdWorkshop> implements IBdWorkshopService {

    @Autowired
    private BdWorkshopMapper bdWorkshopMapper;

    /**
     * 查询车间列表
     *
     * @param bdWorkshop 车间
     * @return 车间
     */
    @Override
    public List<BdWorkshop> selectBdWorkshopList(BdWorkshop bdWorkshop)
    {
        List<BdWorkshop> bdWorkshopList = bdWorkshopMapper.selectList(buildQueryWrapper(bdWorkshop));
        return bdWorkshopList;
    }


    private LambdaQueryWrapper<BdWorkshop> buildQueryWrapper(BdWorkshop query) {
        Map<String, Object> params = query.getParams();
        LambdaQueryWrapper<BdWorkshop> lqw = Wrappers.lambdaQuery();
        lqw.eq(StringUtils.isNotBlank(query.getNumber()), BdWorkshop::getNumber, query.getNumber());
        lqw.like(StringUtils.isNotBlank(query.getName()), BdWorkshop::getName, query.getName());
        lqw.eq(StringUtils.isNotBlank(query.getPerson()), BdWorkshop::getPerson, query.getPerson());
        lqw.eq(StringUtils.isNotBlank(query.getStatus()), BdWorkshop::getStatus, query.getStatus());
        lqw.orderByDesc(BdWorkshop::getCreateTime);
        return lqw;
    }

}
